#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
char s1[1010];
char s2[1010];
int len1,len2;
int nt[1010];
void getnt()
{
	nt[1] = 0;
	int i,t;
	i = 0,t=-1;
	while(i<=len)
	{
		if(t==-1||s2[i]==s2[t])
		{
			t++;
			i++;
			nt[i]=t;
		}
		else
		{
			t = nt[t];
		}
	}
}
int kmp()
{
	getnt();
	int i,j,ans;
	i = j = 1;
	ans = 0;
	while(i<=len1)
	{
		if(j==0||s1[i]==s2[j])
		{
			j++;
			i++;
		}
		else j = nt[j];
		if(j == len2+1)
		{
			j = 1;
			ans++;
		}
	}
	return ans;
}
int main()
{
	while(scanf(" %s",s1)!=EOF)
	{
		if(strcmp("#",s1)==0) return 0;
		scanf(" %s",s2+1);
		len1 = strlen(s1+1);
		len2 = strlen(s2+1);
		int ans = kmp();
		printf("%d\n",ans);
	}
}
